
<%@ page import="org.product.Product" %>
<table>
	<thead>
		<tr>
			<util:remoteSortableColumn controller="product" action="search" params="[q: params.qProduct]" property="productCode" 
				title="${message(code: 'product.productCode.label', default: 'Product Code')}" style="width: 50px" update="list-product"/>
				
			<util:remoteSortableColumn controller="product" action="search" params="[q: params.qProduct]" property="productName" 
				title="${message(code: 'product.productName.label', default: 'product Name')}" style="width: 70px" update="list-product"/>
				
			<util:remoteSortableColumn controller="product" action="search" params="[q: params.qProduct]" property="productSpec" 
				title="${message(code: 'product.productSpec.label', default: 'product spec')}" update="list-product"/>
				
			<util:remoteSortableColumn controller="product" action="search" params="[q: params.qProduct]" property="unit" 
				title="${message(code: 'product.unit.label', default: 'unit')}" update="list-product" style="width: 30px"/>
				
			<util:remoteSortableColumn controller="product" action="search" params="[q: params.qProduct]" property="productPackage" 
				title="${message(code: 'product.productPackage.label', default: 'productPackage')}" update="list-product"/>
			
			<util:remoteSortableColumn controller="product" action="search" params="[q: params.qProduct]" property="stockNum" 
				title="${message(code: 'product.stockNum.label', default: 'stock Nume')}" update="list-product"/>
				
			<util:remoteSortableColumn controller="product" action="search" params="[q: params.qProduct]" property="price" 
				title="${message(code: 'product.price.label', default: 'price')}" style="width: 50px" update="list-product"/>
			<th>
				${message(code: 'product.productDes.label', default: 'Product Des')}
			</th>
			
		</tr>
	</thead>
	<tbody>
	<g:each in="${searchResult?.results}" status="i" var="productInstance">
		<tr class="${(i % 2) == 0 ? 'even' : 'odd'}">
		
			<td><g:link controller="product" action="view" id="${productInstance.id}" target="_blank">${fieldValue(bean: productInstance, field: "productCode")}</g:link></td>
		
			<td>${fieldValue(bean: productInstance, field: "productName")}</td>
			<td>${fieldValue(bean: productInstance, field: "productSpec")}</td>
			<td>${fieldValue(bean: productInstance, field: "unit")}</td>
			<td>${fieldValue(bean: productInstance, field: "productPackage")}</td>
			<td>${fieldValue(bean: productInstance, field: "stockNum")}</td>
			<td>${fieldValue(bean: productInstance, field: "price")}</td>
			<td>${fieldValue(bean: productInstance, field: "productDes")}</td>
		</tr>
	</g:each>
	</tbody>
</table>
<div class="paging">
         <g:if test="${searchResult?.total >0}">
            <g:set var="totalPages" value="${Math.ceil(searchResult.total / searchResult.max)}" />
            <g:if test="${totalPages == 1}">
            	<span class="currentStep">1</span>
            	
            </g:if>
            <g:else>
            	 <util:remotePaginate controller="product" action="search" params="[q:params.q,offset:params.offset]" total="${searchResult?.total}"
                                   update="list-product" max="10"/>
            </g:else>
        </g:if>
        <g:else>
	        <span>there is no data</span>
	     </g:else>
  </div>
